package com.aiyan.edu.framework.model.response;

import lombok.ToString;

/**
 * 公共结果定义
 *
 * @author: zqzhou
 * @create: 2019/10/05 22:51
 **/
@ToString
public enum CommonCode implements ResultCode {

    SUCCESS(true, 1000, "操作成功！"),
    FAIL(false, 0000, "操作失败！"),
    INVALID_PARAM(false, 1001, "非法参数！"),
    SERVER_ERROR(false, 1002, "系统繁忙，请稍后重试！"),
    UNAUTHENTICATED(false, 1003, "此操作需要登录系统！"),
    TOKENEXPIRES(false, 1005, "当前会话无效！"),
    NOTOKEN(false, 1006, "此操作需要携带令牌！"),
    UNAUTHORISE(false, 1004, "权限不足，无权操作！"),
    FALLBACK(false, 1007, "服务异常，请稍后重试！");

    /**
     * 操作是否成功
     * true 操作成功
     * false 操作失败
     */
    private boolean success;

    /**
     * 响应代码
     */
    private int code;

    /**
     * 提示信息
     */
    private String message;

    private CommonCode(boolean success, int code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    @Override
    public boolean success() {
        return this.success;
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String message() {
        return this.message;
    }
}
